import React, { Component } from 'react'
import PubSub from 'pubsub-js';

export default class HeroSearch extends Component {
  state = {
    keyword: ''
  }
  render() {
    return (
        <div className="form" >
            <input type="text" value={this.state.keyword} onChange={this.save} />
            <button onClick={this.search}>搜索</button>
        </div>
    )
  }

  save = (e) => {
    this.setState({
      keyword: e.target.value
    })
  }

  search = () => {
    //获得关键字  频道
    // this.state.keyword
    PubSub.publish('lolkeyword', this.state.keyword);
  }
}
